Class symantec.itools.db.beans.dbnav.model.builder.ThreadLimiter
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class symantec.itools.db.beans.dbnav.model.builder.ThreadLimiter

Object
   |
   +----symantec.itools.db.beans.dbnav.model.builder.ThreadLimiter

public class ThreadLimiter
extends Object
This re-usable class enforces a restricted number of clients simultaneously using some unspecified resource. Say if you had an open-ended (unlimited) recursive mechanism spawning threads, you would want to ensure that only so many threads in total are active at any one time. Class ThreadLimiter can enforce such a limitation by handing out "tickets" (or licenses) to clients, so that they can "proceed" with whatever they wish. Entities applying for a ticket when no more tickets are available will block until a ticket is released by another entity.

Version:
1.0 06/16/98
Author:
Hristo Tonev

Method Index

 o getInstance()
 o getTicket()
Apply for a ticket.
 o returnTicket()
A client has done whatever it needed to do and wants to give up its ticket.

Methods

 o getInstance
public static synchronized symantec.itools.db.beans.dbnav.model.builder.ThreadLimiter getInstance()
 o getTicket
public synchronized int getTicket()
Apply for a ticket. If tickets are still available, give client a ticket and record its issue. If all tickets are currently issued, block (put client thread to sleep) until a ticket becomes available again (and gets recycled). Tickets can only be returned via the returnTicket() method.

 o returnTicket
public synchronized void returnTicket()
A client has done whatever it needed to do and wants to give up its ticket. Take ticket back and recycle it for future clients. Wake up a random thread waiting to get a ticket of its own.


All Packages  Class Hierarchy  This Package  Previous  Next  Index